package com.glsc.ngateway.common.base.repo.oracle.ecology;

import com.glsc.ngateway.common.api.oaflow.dto.oaflow.WorkflowBaseQueryParamDto;
import com.glsc.ngateway.common.base.domain.oracle.ecology.WorkflowBase;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface WorkflowBaseRepository extends JpaRepository<WorkflowBase, Long>, JpaSpecificationExecutor<WorkflowBase> {

    @Query(value = "select t from WorkflowBase t " +
            "where 1=1 " +
            "and ( :#{#param.workflowname} is null or t.workflowname like CONCAT('%', :#{#param.workflowname}, '%')) " +
            "")
    Page<WorkflowBase> page(Pageable pageable, WorkflowBaseQueryParamDto param);

    WorkflowBase findOneById(Long Id);
}
